package com.wait.onlinepicture.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wait.onlinepicture.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.wait.onlinepicture.model.dto.file.UploadPictureResult;
import com.wait.onlinepicture.model.dto.picture.*;
import com.wait.onlinepicture.model.entity.User;

import com.wait.onlinepicture.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wait.onlinepicture.model.vo.picture.PictureVO;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * @author Wait葡萄成熟时
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-03-17 22:02:10
 */
public interface PictureService extends IService<Picture> {
    /**
     * description 上传图片（可重新上传）
     * author Wait葡萄成熟时
     * date 上午10:00 2025/3/18
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * description 构建QueryWrapper查询
     * author Wait葡萄成熟时
     * date 上午10:29 2025/3/18
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * description 获取单个图片封装
     * author Wait葡萄成熟时
     * date 上午10:29 2025/3/18
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * description 分页获取图片封装
     * author Wait葡萄成熟时
     * date 上午12:01 2025/3/19
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * description 图片数据校验方法，用于更新和修改图片时进行判断
     * author Wait葡萄成熟时
     * date 上午12:10 2025/3/19
     */
    void validPicture(Picture picture);

    /**
     * description 图片审核
     * author Wait葡萄成熟时
     * date 下午4:27 2025/3/26
     */

    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * description 给审核的图片设置审核参数
     * author Wait葡萄成熟时
     * date 下午4:43 2025/3/26
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * description 批量抓取和创建图片
     * author Wait葡萄成熟时
     * date 上午12:46 2025/3/28
     */
    int uploadPictureByBatch(
            PictureUploadByBatchRequest pictureUploadByBatchRequest,
            User loginUser
    );

    /**
     * description 删除图片文件（cos中）
     * author Wait葡萄成熟时
     * date 上午1:16 2025/4/2
     */
    void clearPictureFile(Picture oldPicture);

    /**
     * description 空间的图片权限控制(管理员和本人可用）
     * author Wait葡萄成熟时
     */
    void checkPictureAuth(User loginUser, Picture picture);

    /**
     * description 删除图片（较多业务，单独抽出）
     * author Wait葡萄成熟时
     */
    void deletePicture(long pictureId, User loginUser);

    /**
     * description 编辑图片（较多业务，单独抽出）
     * author Wait葡萄成熟时
     */
    void editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * description 图片分页查询带缓存（较多业务，单独抽出）
     * author Wait葡萄成熟时
     */
    Page<PictureVO> listPictureVOByPage(PictureQueryRequest pictureQueryRequest, HttpServletRequest request);

    /**
     * description 按颜色查询图片
     * author Wait葡萄成熟时
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);
    /**
     * description批量修改图片
     * author Wait葡萄成熟时
     */
    @Transactional(rollbackFor = Exception.class)
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}

